<?php  

require_once("classes/Status.class.php");
require_once("model/Model.class.php");

class StatusModel extends Model{
    
    public function __construct(){
        $this->setTabela("status");
    }
    
    public function inserir(Status $status){
        $campos = array(
                        'status',
                        'idstatus',
                        's',
                  );
        $valores = array(
                        $status->getIdStatus(),
                        $status->getStatus(),
                        $status->getAtivo()
                    );          
        return $this->insert($campos, $valores);
    }
    
    public function alterar(Status $status){
        $campos = array(
                        'status',
                        'idstatus',
                        's',
                  );
        $valores = array(
                        $status->getIdStatus(),
                        $status->getStatus(),
                        $status->getAtivo()
                    );
        $criteria = "idstatus = {$status->getIdStatus()}";            
        return $this->update($campos, $valores, $criteria);
    }
    
    public function deletar(Status $status){
        $criteria = "idstatus = {$status->getIdStatus()}";    
        return $this->delete($criteria); 
    }
    
    public function selecionar(Status $status){
        $criteria = "idstatus = {$status->getIdStatus()}";      
        $result = $this->select($criteria);
        return array("idstatus"=>$result['idstatus'],"status"=>$result['status'],"ativo"=>$result['ativo']);
    }
    
    public function selecionarTodos(){
        $result = $this->selectAll();
        foreach ($result as $key => $value):
            $idstatus[] = $value['idstatus'];
            $status[] = $value['status'];
            $ativo[] = $value['idstatus'];
        endforeach;
        return array("idstatus"=>$idstatus,"status"=>$status,"ativo"=>$ativo);
    }
}
?>